﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace PhotoNamingService
{
    public abstract class PhotoNamingBase : IPhotoNaming
    {
        public string InterfaceName
        {
            get
            {
                return this.GetType().Name;
            }
        }

        #region static fields and functions
        protected static PhotoNameConfig _option = new PhotoNameConfig();
        public static PhotoNameConfig Option
        {
            get
            {
                return _option;
            }
        }

        protected static void LoadConfig()
        {
            if (!File.Exists(_option.ConfigFilePath))
            {
                _option.Save();
                FileInfo info = new FileInfo(_option.ConfigFilePath);
                if (info.Exists)
                {
                    info.Attributes = FileAttributes.Hidden;
                }
            }
            _option.Load();
        }

        static PhotoNamingBase()
        {
            LoadConfig();
        }
        #endregion

        protected bool _bInited = false;
        public bool Inited
        {
            get
            {
                return _bInited;
            }
        }

        protected bool _bExited = false;
        public bool Exited
        {
            get
            {
                return _bExited;
            }
        }

        protected string _error = "";
        public string ErrorMessage
        {
            get
            {
                return _error;
            }
        }

        public virtual bool Init(string inParams)
        {
            _bInited = true;
            return true;
        }

        public virtual bool Exit(string inParams)
        {
            _bExited = true;
            return true;
        }

        public abstract bool GetPhotoName(string inParams, out string PhotoName);     
    }
}
